home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
050
/
bix03.arc
/
DIR.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1986-08-04
|
2KB
|
117 lines
PROGRAM Testofdir;
TYPE Str=STRING[12];
Arr=ARRAY[1..64] OF Str;
VAR Arry:Arr;
J:INTEGER;
(************************************************************************)
PROCEDURE Qsort(VAR LN:Arr;N:INTEGER);
VAR Stack:ARRAY[1..20] OF INTEGER;
L,I,J,R,S:INTEGER;
X:Str;
(************************************************************************)
PROCEDURE Swap(VAR X,I:Str);
VAR T:Str;
BEGIN
T:=X;
X:=I;
I:=T;
END;
BEGIN
S:=1;Stack[S]:=1;Stack[S+1]:=N;
WHILE S>0 DO
BEGIN
L:=Stack[S];R:=Stack[S+1];S:=S-2;
WHILE L<R DO
BEGIN
I:=L; J:=R; X:=LN[(L+R) DIV 2];
WHILE I<=J DO
BEGIN
WHILE LN[I]<X DO I:=I+1;
WHILE X<LN[J] DO J:=J-1;
IF I<=J THEN
BEGIN
Swap(LN[I],LN[J]);
I:=I+1;
J:=J-1;
END;
END;
IF I<R THEN
BEGIN
S:=S+2;
Stack[S]:=I;
Stack[S+1]:=R;
END;
R:=J;
END;
END;
END;
(************************************************************************)
PROCEDURE Dir(VAR Arry:Arr; VAR J:INTEGER; Disk:INTEGER);
CONST Setdma =26;
Search_First =17;
Search_Next =18;
VAR Buffer : ARRAY [0..127] OF BYTE;
Fcbuff : ARRAY [0..32] OF BYTE;
Name : Str;
A : BYTE;
I : INTEGER;
BEGIN
Name:=''; J:=0;
Bdos(Setdma,ADDR(Buffer));
Fcbuff[0]:=Disk;
FOR I:=1 TO 11 DO Fcbuff[I]:=ORD('?');
FOR I:=12 TO 32 DO Fcbuff[I]:=0;
A:=Bdos(Search_First,ADDR(Fcbuff));
WHILE A<>$Ff DO
BEGIN
A:=A * 32;
FOR I:=A+1 TO A+11 DO
Name:=Name+CHR(Buffer[I]);
J:=J+1;
Arry[J]:=Name;
Name:='';
A:=Bdos(Search_Next);
END;
END;
(************************************************************************)
PROCEDURE Print(Arry:Arr; J,Col:INTEGER);
VAR I,T,K:INTEGER;
BEGIN
I:=1; T:=J DIV Col;
WHILE I<=J DIV Col DO
BEGIN
WRITE('| ');
FOR K:=0 TO Col-1 DO
WRITE(Arry[I+K*T],' | ');
WRITELN;
I:=I+1;
END;
IF J MOD Col<>0 THEN WRITE('| ');
FOR K:=0 TO J MOD Col DO
WRITE(Arry[I+K*T],' | ');
WRITELN;
END;
BEGIN
Dir(Arry,J,1);
Qsort(Arry,J);
Print(Arry,J,5);
WRITELN;
Dir(Arry,J,2);
Qsort(Arry,J);
Print(Arry,J,5);
END.